import React from "react";
import {inject, observer} from "mobx-react";
import {Tools} from "weaver-mobile";
import {withRouter} from "react-router-dom";
import {WrOrg} from "../../../public";
import {observable, toJS} from "mobx";

const getLabel = Tools.getLabel;

/**
 * 考核方案-下属方案或组织部门
 * jiansong 2019/11/8
 */
@inject("programViewStore")
@withRouter
@observer
export default class Org extends React.Component {

    constructor(props) {
        super(props);
        this.store = this.props.programViewStore;
    }

    render() {
        const {orgStore, onFormChange, programDetail} = this.store;
        return (
            <WrOrg
                orgStore={orgStore}
                type={this.props.type}
                onSelect={(id, data, type) => {
                    if (this.props.type == "sub" || (this.props.type == "org" && type == 3)) {
                        onFormChange({"resourceid": id, "programid": "", "programtype": ""});
                        programDetail();
                        this.store.showtype = "detail";
                    }
                }}
            />
        )
    }

}